<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>东家帮-用户注册</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
	<meta name="format-detection" content="telephone=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="stylesheet" href="${base}/css/common.css"/>
	<link rel="stylesheet" href="${base}/css/index2.css"/>
	<base href="${base}/index/">
	<style type="text/css">
	  </style>
</head>
<body>
<div class="register">
	<img src="${base}/images/logo.png" class="logo" />
	<h1 >放心，东家帮</h1>
	<form method="post" name="loginform"  id="loginform" class="am-form" action="${base}/index/usersave2">
	<div class="line"><input type="tel" name="phone" id="phone" placeholder="手机号" ></div>
	<div class="line"><input type="tel" name="code" id="code" placeholder="验证码" maxlength="4" style="width: 28%;"><div id="sendcode"><a onclick="sendValidationCode();" id="sendValidationCodebt">获取验证码</a></div></div>
	<div class="line"><input type="password" name="password" id="password" placeholder="新密码" ></div>
	<div class="line" style="margin-top: 36px;border:0px;margin-left: 8%;"><input type="button" id="submit"  onclick="save();" value="完成" class="btn" /></div>
	</form>
</div>
</body>
<script type="text/javascript" src="${base}/js/common.js"></script>
<script src="${base}/js/jquery1.10.2.min.js" ></script>
<script src="${base}/js/jquery.form.js" ></script>
<script>
	var InterValObj; //timer变量，控制时间
	var count = 60; //间隔函数，1秒执行
	var curCount;//当前剩余秒数
	curCount = count;
	function sendValidationCode(){
	    var mobile = $("#phone").val();
	    var url1 = "${base}/index/sendcode";
	    $.ajax({
	        url: url1 + "?phone=" + mobile,
	        type: 'get',
	        success: function (data) {
	        	alert(data);
	        	InterValObj = window.setInterval(SetRemainTime, 1000);
	        }
	    });
	
	}
	
	function SetRemainTime() {
	    if (curCount == 0) {
	        window.clearInterval(InterValObj);//停止计时器
	        $("#sendValidationCodebt").removeAttr("disabled");//启用按钮
	        $("#sendValidationCodebt").html("重发验证码");
	    }
	    else {
	        curCount--;
	        $("#sendValidationCodebt").html("重发验证码(" + curCount + ")");
	    }
	}

	function save(){
		var options = {
            success:  showResponse2,  //处理完成的回调函数
            resetForm: true
        };
        $("#loginform").ajaxSubmit(options);
	}
	function showResponse2(responseText)  {
		alert(responseText);
		window.location.href = "${base}/index/main";
	}
</script>
</html>
